import { onUpdated } from "vue";

export default {
    // 挂载完成后执行
    mounted(el, bindings) {
        const { curClass, itemClass, curId } = bindings.value;

        el.oList = el.getElementsByClassName(itemClass);
        el.curClass = curClass;
        el.itemClass = itemClass;

        el.oList[curId - 1].className = `${itemClass} ${curClass} `;
    },
    // 传入的属性改变的时候会执行
    updated(el, bindings) {
        const { curClass, itemClass, oList } = el,
            oldId = bindings.oldValue.curId,
            curId = bindings.value.curId;

        oList[oldId - 1].className = `${itemClass}`;
        oList[curId - 1].className = `${itemClass} ${curClass} `;
    }

}
